package com.java.tutorials.Class.anonymous;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
 * Created by xuzhike on 2016/3/14.
 * http://www.java2s.com/Code/Java/Class/Anonymousinnerclass.htm
 *
 Anonymous inner class
 */
public class SimpleEvent {

    public static void main(String[] args) {
        JButton close = new JButton("Close");
        close.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                System.exit(0);
            }

        });
        JFrame f = new JFrame();
        f.add(close);

        f.setSize(300, 200);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setVisible(true);
    }
}
